package com.zijiebutiao.config;

import com.zijiebutiao.utils.ResultVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Date 2023/3/8 14:55
 * @Author 时间刺客
 */
@ControllerAdvice
@Slf4j
public class GlobalExceptionHandler {
    @ExceptionHandler(Exception.class)
    @ResponseBody
    public ResultVo catchAllExceptionHandler(Exception exception){
        exception.printStackTrace();
        log.info("err:---------->"+exception.getMessage());
//        log.debug("err:---------->"+exception.getMessage());

        return  ResultVo.error(500,"服务器维护中，请联系管理员！");
    }
}
